package com.midcontainer {
	import com.greensock.TweenMax;
	import com.greensock.plugins.TintPlugin;
	import com.greensock.plugins.TweenPlugin;
	import com.reusables.ArrowBtn;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	TweenPlugin.activate([TintPlugin]);
	public class ArrowButtonHolder extends Sprite {
		private var _myFont : Font;
		private var _myFormat : TextFormat;
		private var _txtField : TextField;
		public var _leftArrowBtn : ArrowBtn;
		public var _rightArrowBtn : ArrowBtn;
		private var _arrowBtnHolder : Sprite;

		public function ArrowButtonHolder() {
			addArrowBtns();
		}

		private function addArrowBtns() : void {
			_arrowBtnHolder = new Sprite();
			_arrowBtnHolder.graphics.beginFill(0x00000C, 0);
			_arrowBtnHolder.graphics.drawRect(0, 0, 220, 50);
			_arrowBtnHolder.graphics.endFill();
			_arrowBtnHolder.x = 0;
			_arrowBtnHolder.y = 0;
			addChild(_arrowBtnHolder);

			_arrowBtnHolder.x = 0;
			_arrowBtnHolder.y = 0;

			_leftArrowBtn = new ArrowBtn();
			_leftArrowBtn.x = Math.round(_arrowBtnHolder.width / 2) - 75;
			_leftArrowBtn.y = 25;
			_arrowBtnHolder.addChild(_leftArrowBtn);

			_rightArrowBtn = new ArrowBtn();
			_rightArrowBtn.x = Math.round(_arrowBtnHolder.width / 2) + 75;
			_rightArrowBtn.y = 25;
			_rightArrowBtn.scaleX *= -1;
			_arrowBtnHolder.addChild(_rightArrowBtn);

			_myFont = new Font1();

			_myFormat = new TextFormat();
			_myFormat.font = _myFont.fontName;
			_myFormat.size = 15;
			_myFormat.letterSpacing = 1;
			_myFormat.align = TextFormatAlign.CENTER;

			_txtField = new TextField();
			_txtField.x = 50;
			_txtField.y = 15;

			_txtField.width = 120;
			_txtField.height = 20;
			_txtField.selectable = false;
			_txtField.textColor = 0x000000;
			_txtField.defaultTextFormat = _myFormat;
			_txtField.embedFonts = true;
			_txtField.antiAliasType = AntiAliasType.NORMAL;
			_txtField.text = "2 to 4 of 6";
			_arrowBtnHolder.addChild(_txtField);

			_leftArrowBtn.addEventListener(MouseEvent.MOUSE_OVER, onRollover);
			_leftArrowBtn.addEventListener(MouseEvent.MOUSE_OUT, onRollout);
			_rightArrowBtn.addEventListener(MouseEvent.MOUSE_OVER, onRollover);
			_rightArrowBtn.addEventListener(MouseEvent.MOUSE_OUT, onRollout);
		}

		private function onRollover(evt : Event) : void {
			TweenMax.to(evt.currentTarget, 0.5, {colorMatrixFilter:{colorize:0x000000, amount:0.3}});
		}

		private function onRollout(evt : Event) : void {
			TweenMax.to(evt.currentTarget, 0.5, {colorMatrixFilter:{colorize:0xffffff, amount:1}});
		}
	}
}